package cn.tedu.medicalappointmentsystemk.dao.persist.repository.impl;

import cn.tedu.medicalappointmentsystemk.dao.persist.mapper.AppointmentMapper;
import cn.tedu.medicalappointmentsystemk.dao.persist.repository.AppointmentRepository;
import cn.tedu.medicalappointmentsystemk.pojo.bo.AppointmentSelectBO;
import cn.tedu.medicalappointmentsystemk.pojo.bo.AppointmentSelectByUserIdBO;
import cn.tedu.medicalappointmentsystemk.pojo.po.AppointmentPO;
import com.github.pagehelper.Page;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import java.util.Date;
import java.util.List;

@Repository
public class AppointmentRepositoryImpl implements AppointmentRepository {
    @Autowired
    private AppointmentMapper mapper;
    @Override
    public Integer insert(AppointmentPO po) {
        return mapper.insert(po);
    }

    @Override
    public Page<AppointmentSelectBO> selectAppointment() {
        return mapper.selectList();
    }

    @Override
    public AppointmentPO selectAppointment(Long id) {
        return mapper.selectById(id);
    }

    @Override
    public Integer deleteAppointmentById(Long id) {
        return mapper.deleteById(id);
    }

    @Override
    public Integer updateAppointment(AppointmentPO po) {
        return mapper.updateById(po);
    }

    @Override
    public AppointmentSelectByUserIdBO selectByUserId(Long id) {
        return mapper.selectByUserId(id);
    }

    @Override
    public Page<AppointmentSelectByUserIdBO> selectAppointmentsByUserId(Long id) {
        return mapper.selectAppointmentsByUserId(id);
    }

    @Override
    public Long selectAppointmentByCreateDate(Date createDate,Long patientId) {
        return mapper.selectAppointmentByCreateDate(createDate,patientId);
    }

    @Override
    public Integer selectTotal() {
        return mapper.selectCount(null);
    }

    @Override
    public Integer selectToday() {
        return mapper.selectCountToday();
    }

    @Override
    public Page<AppointmentSelectBO> searchToday() {
        return mapper.searchToday();
    }

    @Override
    public Page<AppointmentSelectBO> searchLastWeek() {
        return mapper.searchLastWeek();
    }

    @Override
    public Page<AppointmentSelectBO> searchLastMonth() {
        return mapper.searchLastMonth();
    }

    @Override
    public Integer selectLastMonth() {
        return mapper.selectCountLastMonth();
    }

    @Override
    public List<AppointmentSelectBO> selectByNickname(String nickname) {
        return mapper.selectByNickname(nickname);
    }

}
